home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 April / SGI IRIX 6.5 Applications 2004 April.iso / dist / mozilla.idb / var / netscape / mozilla / chrome / comm.jar.z / comm.jar / content / cookie / pref-popups.xul < prev   
Extensible Markup Language  |  2003-11-11  |  10KB  |  260 lines

  1. <?xml version="1.0"?> 
  2.  
  3. <!-- ***** BEGIN LICENSE BLOCK *****
  4.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.    -
  6.    - The contents of this file are subject to the Mozilla Public License Version
  7.    - 1.1 (the "License"); you may not use this file except in compliance with
  8.    - the License. You may obtain a copy of the License at
  9.    - http://www.mozilla.org/MPL/
  10.    -
  11.    - Software distributed under the License is distributed on an "AS IS" basis,
  12.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.    - for the specific language governing rights and limitations under the
  14.    - License.
  15.    -
  16.    - The Original Code is mozilla.org code.
  17.    -
  18.    - The Initial Developer of the Original Code is
  19.    - Netscape Communications Corporation.
  20.    - Portions created by the Initial Developer are Copyright (C) 2002
  21.    - the Initial Developer. All Rights Reserved.
  22.    -
  23.    - Contributor(s):
  24.    -
  25.    - Alternatively, the contents of this file may be used under the terms of
  26.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  27.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.    - in which case the provisions of the GPL or the LGPL are applicable instead
  29.    - of those above. If you wish to allow use of your version of this file only
  30.    - under the terms of either the GPL or the LGPL, and not to allow others to
  31.    - use your version of this file under the terms of the MPL, indicate your
  32.    - decision by deleting the provisions above and replace them with the notice
  33.    - and other provisions required by the LGPL or the GPL. If you do not delete
  34.    - the provisions above, a recipient may use your version of this file under
  35.    - the terms of any one of the MPL, the GPL or the LGPL.
  36.    -
  37.    - ***** END LICENSE BLOCK ***** -->
  38.  
  39. <?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
  40.  
  41. <!DOCTYPE page [
  42. <!ENTITY % prefPopupsDTD SYSTEM "chrome://cookie/locale/pref-popups.dtd" >
  43. %prefPopupsDTD;
  44. ]>
  45.  
  46. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  47.       id="popupsPanel"
  48.       onload="init()"
  49.       headertitle="&title;">
  50.           
  51.   <script type="application/x-javascript">
  52.     <![CDATA[
  53.  
  54.       var _elementIDs = ["popupPolicy","playSound","playSoundUrl","displayIcon","removeBlacklist","prefillWhitelist"];
  55.  
  56.       const nsIPermissionManager = Components.interfaces.nsIPermissionManager
  57.       const popupType = nsIPermissionManager.POPUP_TYPE;
  58.  
  59.       var gPolicyCheckbox;
  60.       var gSoundCheckbox;
  61.       var gSoundUrlBox;
  62.       var gSoundUrlButton;
  63.       var gPreviewSoundButton;
  64.       var gIconCheckbox;
  65.  
  66.       var permissionManager;
  67.       var ioService;
  68.  
  69.       function init() {
  70.         parent.initPanel("chrome://cookie/content/pref-popups.xul");
  71.  
  72.         permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
  73.                                       .getService(Components.interfaces.nsIPermissionManager);
  74.  
  75.         ioService = Components.classes["@mozilla.org/network/io-service;1"]
  76.                               .getService(Components.interfaces.nsIIOService);
  77.  
  78.         gPolicyCheckbox = document.getElementById("popupPolicy");
  79.         gSoundCheckbox = document.getElementById("playSound");
  80.         gSoundUrlBox = document.getElementById("playSoundUrl");
  81.         gSoundUrlButton = document.getElementById("selectSound");
  82.         gPreviewSoundButton = document.getElementById("previewSound");
  83.         gIconCheckbox = document.getElementById("displayIcon");   
  84.  
  85.         var removeBlacklist = (document.getElementById("removeBlacklist").getAttribute("value") == "true");
  86.         if (removeBlacklist) {
  87.           clearBlacklist();
  88.           document.getElementById("removeBlacklist").setAttribute("value", false);
  89.         }
  90.  
  91.         var prefillWhitelist = (document.getElementById("prefillWhitelist").getAttribute("value") == "true");        
  92.         if (prefillWhitelist) {          
  93.           loadWhitelist();
  94.           document.getElementById("prefillWhitelist").setAttribute("value", false);
  95.         }
  96.  
  97.         if (!parent.window.opener.location) // opened from About Popups menuitem
  98.           gPolicyCheckbox.checked = true;
  99.  
  100.         setButtons();
  101.       }
  102.  
  103.       function clearBlacklist() {
  104.         var enumerator = permissionManager.enumerator;
  105.         var hosts = [];
  106.   
  107.         while (enumerator.hasMoreElements()) {                
  108.           var permission = enumerator.getNext();
  109.           if (permission) {
  110.             permission = permission.QueryInterface(Components.interfaces.nsIPermission);
  111.             if ((permission.type == popupType) && (permission.capability == nsIPermissionManager.DENY_ACTION))
  112.               hosts[hosts.length] = permission.host;
  113.           }
  114.         }
  115.         
  116.         for (var i = 0; i < hosts.length; i++) {
  117.           permissionManager.remove(hosts[i], popupType);
  118.         }    
  119.       
  120.       }
  121.  
  122.       function loadWhitelist() {
  123.         try {
  124.           var whitelist;
  125.           var hosts;
  126.           var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  127.                                       .getService(Components.interfaces.nsIPrefService);
  128.           var prefs = prefService.getBranch(null);
  129.           whitelist = prefs.getComplexValue("privacy.popups.default_whitelist",
  130.                                             Components.interfaces.nsIPrefLocalizedString).data;
  131.           hosts = whitelist.split(",");
  132.  
  133.           for (var i = 0; i < hosts.length; i++) {
  134.             var host = hosts[i];
  135.             host = "http://" + host;
  136.             var uri = ioService.newURI(host, null, null);
  137.             permissionManager.add(uri, popupType, true);
  138.           }
  139.         } 
  140.         catch (ex) { }
  141.       }
  142.  
  143.       function setButtons() {
  144.         var exceptionsButton = document.getElementById("exceptionsButton");
  145.         exceptionsButton.disabled = !gPolicyCheckbox.checked;
  146.  
  147.         if (!gPolicyCheckbox.checked) {
  148.           gSoundCheckbox.disabled = true;
  149.           gSoundUrlBox.disabled = true;
  150.           gSoundUrlButton.disabled = true;
  151.           gPreviewSoundButton.disabled = true;
  152.           gIconCheckbox.disabled = true;
  153.         }
  154.         else {
  155.           gSoundCheckbox.disabled = false;
  156.           gSoundUrlBox.disabled = false;
  157.           gSoundUrlButton.disabled = false;
  158.           gPreviewSoundButton.disabled = false;
  159.           gIconCheckbox.disabled = false;
  160.                   
  161.           enableSoundUrl(gSoundCheckbox.checked);
  162.         }
  163.       }
  164.  
  165.       function selectSound() {
  166.         var nsIFilePicker = Components.interfaces.nsIFilePicker;
  167.         var filepicker = Components.classes["@mozilla.org/filepicker;1"]
  168.                                    .createInstance(nsIFilePicker);
  169.  
  170.         filepicker.init(window, document.getElementById("selectSound").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
  171.         filepicker.appendFilters(nsIFilePicker.filterAll);
  172.  
  173.         var ret = filepicker.show();
  174.         if (ret == nsIFilePicker.returnOK)
  175.           gSoundUrlBox.value = filepicker.file.path;
  176.         
  177.         onSoundInput();
  178.       }
  179.  
  180.       function previewSound() {
  181.         var soundUrl = gSoundUrlBox.value;
  182.         var sound = Components.classes["@mozilla.org/sound;1"]
  183.                               .createInstance(Components.interfaces.nsISound);
  184.         if (soundUrl.indexOf("file://") == -1) {
  185.           sound.playSystemSound(soundUrl);
  186.         }
  187.         else {
  188.           var url = Components.classes["@mozilla.org/network/standard-url;1"]
  189.                               .createInstance(Components.interfaces.nsIURL);
  190.           url.spec = soundUrl;
  191.           sound.play(url)
  192.         }        
  193.       }
  194.  
  195.       function enableSoundUrl(soundChecked) {
  196.         gSoundUrlBox.disabled = !soundChecked;
  197.         gSoundUrlButton.disabled = !soundChecked;
  198.         if (soundChecked && gSoundUrlBox.value) {
  199.           gPreviewSoundButton.disabled = false;
  200.         }
  201.         else
  202.           gPreviewSoundButton.disabled = true;
  203.       }
  204.  
  205.       function onSoundInput() {
  206.         gPreviewSoundButton.disabled = gSoundUrlBox.value == "";
  207.       }
  208.  
  209.       function viewPopups() {
  210.         window.openDialog("chrome://communicator/content/popupManager.xul", "",
  211.                           "chrome,resizable=yes,modal=yes", 
  212.                           "",
  213.                           true);
  214.       }
  215.  
  216.     ]]>
  217.   </script>
  218.  
  219.   <groupbox id="popupsArea">
  220.     <caption label="&popupBlocking.label;"/>
  221.  
  222.     <hbox align="center">      
  223.       <checkbox id="popupPolicy" label="&popupBlock.label;" accesskey="&popupBlock.accesskey;"
  224.                 oncommand="setButtons()"
  225.                 preftype="bool" prefstring="dom.disable_open_during_load"
  226.                 prefattribute="checked"/>   
  227.             <spacer flex="1"/>
  228.       <button id="exceptionsButton" label="&popupExceptions.label;"
  229.               accesskey="&popupExceptions.accesskey;"
  230.                     oncommand="viewPopups();"/>
  231.           </hbox>
  232.     <separator class="thin"/>
  233.     <description id="whenBlock">&whenBlock.description;</description>
  234.     <hbox align="center">
  235.       <checkbox id="playSound" label="&playSound.label;"
  236.                 oncommand="enableSoundUrl(this.checked);"
  237.                 preftype="bool" prefstring="privacy.popups.sound_enabled"
  238.                 prefattribute="checked"/>
  239.     </hbox>
  240.     <hbox align="center">
  241.       <textbox flex="1" id="playSoundUrl"
  242.                prefstring="privacy.popups.sound_url" oninput="onSoundInput()"/>
  243.       <button id="selectSound" label="&selectSound.label;" accesskey="&selectSound.accesskey;"
  244.               filepickertitle="&selectSound.title;" oncommand="selectSound();"/>
  245.       <button id="previewSound" label="&previewSound.label;" accesskey="&previewSound.accesskey;"
  246.               oncommand="previewSound();"/>
  247.     </hbox>
  248.     <hbox align="center">
  249.       <checkbox id="displayIcon" label="&displayIcon.label;"
  250.                 preftype="bool" prefstring="privacy.popups.statusbar_icon_enabled"
  251.                 prefattribute="checked"/>
  252.     </hbox>
  253.     <separator class="thin"/>
  254.     <description>&popupNote.description;</description>
  255.     <data id="prefillWhitelist" preftype="bool" prefattribute="value" prefstring="privacy.popups.prefill_whitelist"/>
  256.     <data id="removeBlacklist" preftype="bool" prefattribute="value" prefstring="privacy.popups.remove_blacklist"/>
  257.   </groupbox>
  258.  
  259. </page>
  260.